<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		
		<script>
			
			/**
			 * @param {Object} str   那1串长的字符串
			 * @param {Object} mark  字符串中是否包含的特殊字符
			 */
			function checkOnlyOne(str,mark){
				var flag = false;
				
				var index = str.indexOf(mark);
				console.log(index);
				
				//说明只有1个而且在最末尾
				if(index == str.length-1){
					console.log("有且只有1个");
					flag = true;
					return flag;
				}
				
				//说明最少有1个 而且不末尾
				if(index != -1){
					var newString = str.substring(index+1);
					var xb =newString.indexOf("@");
					if(xb==-1){
						flag = true;
						return flag;
					}
					
				}
				
				return flag;
				
			}
			
			var jg = checkOnlyOne('abc@123','@');
			console.log(jg);
			
		</script>
	</body>
</html>
